/*    */ package system.staros.sblock1;
/*    */ 
/*    */ public class LookupNode extends Node
/*    */ {
/*    */   private VariableNode varNode;
/*    */   private Node keyNode;
/*    */ 
/*    */   public LookupNode(SourcePosition paramSourcePosition, VariableNode paramVariableNode, Node paramNode)
/*    */   {
/* 38 */     super(paramSourcePosition);
/* 39 */     this.varNode = paramVariableNode;
/* 40 */     this.keyNode = paramNode;
/*    */   }
/*    */ 
/*    */   public ZemObject get(Interpreter paramInterpreter) {
/* 44 */     ZemObject localZemObject1 = paramInterpreter.getVariable(this.varNode.getName(), this.varNode.getPosition());
/* 45 */     Object localObject = null;
/* 46 */     if ((localZemObject1 instanceof ZemArray)) {
/* 47 */       int i = this.keyNode.eval(paramInterpreter).toNumber(this.keyNode.getPosition()).intValue();
/* 48 */       return ((ZemArray)localZemObject1).get(i);
/* 49 */     }if ((localZemObject1 instanceof Dictionary)) {
/* 50 */       ZemObject localZemObject2 = this.keyNode.eval(paramInterpreter);
/* 51 */       return ((Dictionary)localZemObject1).get(localZemObject2);
/*    */     }
/* 53 */     throw new InvalidTypeException("lookup expects an array or dictionary.", getPosition());
/*    */   }
/*    */ 
/*    */   public void set(Interpreter paramInterpreter, ZemObject paramZemObject) {
/* 57 */     ZemObject localZemObject1 = paramInterpreter.getVariable(this.varNode.getName(), this.varNode.getPosition());
/* 58 */     Object localObject = null;
/* 59 */     if ((localZemObject1 instanceof ZemArray)) {
/* 60 */       int i = this.keyNode.eval(paramInterpreter).toNumber(this.keyNode.getPosition()).intValue();
/* 61 */       ((ZemArray)localZemObject1).set(i, paramZemObject);
/* 62 */       return;
/* 63 */     }if ((localZemObject1 instanceof Dictionary)) {
/* 64 */       ZemObject localZemObject2 = this.keyNode.eval(paramInterpreter);
/* 65 */       ((Dictionary)localZemObject1).set(localZemObject2, paramZemObject);
/* 66 */       return;
/*    */     }
/* 68 */     throw new InvalidTypeException("lookup expects an array or dictionary.", getPosition());
/*    */   }
/*    */ 
/*    */   public ZemObject eval(Interpreter paramInterpreter)
/*    */   {
/* 73 */     return get(paramInterpreter);
/*    */   }
/*    */ 
/*    */   public String toString()
/*    */   {
/* 78 */     StringBuffer localStringBuffer = new StringBuffer();
/* 79 */     localStringBuffer.append('(');
/* 80 */     localStringBuffer.append("lookup ");
/* 81 */     localStringBuffer.append(this.varNode);
/* 82 */     localStringBuffer.append(' ');
/* 83 */     localStringBuffer.append(this.keyNode);
/* 84 */     localStringBuffer.append(')');
/* 85 */     return localStringBuffer.toString();
/*    */   }
/*    */ }

/* Location:           D:\Марк\!IMPORTANT\staros\archive\version-2.260.zip
 * Qualified Name:     system.staros.sblock1.LookupNode
 * JD-Core Version:    0.6.1
 */